# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=evolution-data-server
pkgver=3.36.5
pkgrel=0
pkgdesc="data server for evolution"
url="https://projects.gnome.org/evolution"
arch="all !mips64"
license="GPL-2.0-or-later"
depends_dev="libgdata-dev gcr-dev icu-dev"
makedepends="$depends_dev gperf flex bison glib-dev gtk+3.0-dev libsecret-dev
	libsoup-dev libxml2-dev nss-dev sqlite-dev krb5-dev gnu-libiconv-dev
	openldap-dev json-glib-dev webkit2gtk-dev libgweather-dev
	cmake libical-dev libcanberra-dev vala gobject-introspection-dev
	gnome-online-accounts-dev libphonenumber-dev"
subpackages="$pkgname-dev $pkgname-lang"
source="https://download.gnome.org/sources/evolution-data-server/${pkgver%.*}/evolution-data-server-$pkgver.tar.xz"

case "$CARCH" in
mips*)	options="!check" ;;
esac

prepare() {
	default_prepare
	mkdir -p "$builddir"/build
}

build() {
	cd "$builddir"/build
	CFLAGS="$CFLAGS -I/usr/include/gnu-libiconv" \
	cmake \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DSYSCONF_INSTALL_DIR=/etc \
		-DCMAKE_BUILD_TYPE=None \
		-DENABLE_GOA=ON \
		-DENABLE_UOA=OFF \
		-DENABLE_INTROSPECTION=ON \
		-DENABLE_VALA_BINDINGS=ON \
		-DWITH_SYSTEMUSERUNITDIR=no \
		-DWITH_PHONENUMBER=ON \
		..
	make
}

check() {
	# failing tests on s390x. -locale tests fail due to musl not supporting LC_ADDRESS.
	case "$CARCH" in
		s390x) ;;
		*) cd build && CTEST_OUTPUT_ON_FAILURE=TRUE ctest -E "(test-book-cache-cursor-change-locale|test-sqlite-cursor-change-locale)"
	esac
}

package() {
	make -C build DESTDIR="$pkgdir" install
}

sha512sums="65ec23a665e3a547b10ad6a6be5f0533db269406c3e8db64a63cffb8e1b410e83b9c39bd7cd5dac5ecd5cf61ef96dc529ba1bd00ad0a09b3bf2c4e98f3d156e3  evolution-data-server-3.36.5.tar.xz"
